<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
    
    
     <?php
   /* header("Content-type: text/html;charset=utf-8");*/
    
     $conn=@mysql_connect("localhost","root","")  or die(mysql_error());
     mysql_query("SET NAMES UTF8");
     @mysql_select_db('guyueyan',$conn) or die(mysql_error()); 
    
     if(isset($_POST['ann'])){
        
        if(isset($_POST['acc']))
            $acc = $_POST['acc'];       //账户名
         
         //判断账户是否存在
        $select1 = "select * from user where account='$acc'";
         $sum = mysql_query($select1);
         if(mysql_num_rows($sum)>0){
             echo '<script>alert("账户已存在！")</script>';
             exit();
         }
         
        if(isset($_POST['code']))
            $code = $_POST['code'];     //密码
    
        if(isset($_POST['codes']))
            $codes = $_POST['codes'];   //邮箱
         
        //判断两次密码是否一致
         if($code != $codes){
             echo '<script>alert("两次密码不一致！")</script>';
             exit();
         }
         
         $qianm = $r = $interest = null;
        if(isset($_POST['qianm']))
            $qianm =  $_POST['qianm'];  //签名
        
        if(isset($_POST['RadioGroup1']))  //性别
            $r = $_POST['RadioGroup1'];
        
        $interest="";                    //兴趣
        if(isset($_POST['interest']))
            foreach($_POST['interest'] as $k)
                $interest .= ($k );
         
       /* print_r($_POST);*/
         //默认昵称
          $select2 = "select max(id) from user";
         $res = mysql_query($select2);
        $id = mysql_fetch_row($res)[0]+1;
         
         
        echo $name;
         
         //向数据库写数据
         $insert = "insert into user values(null,'$r','$acc','$code','$qianm','$interest',null,'$name')";
         if(mysql_query($insert)){
            echo '<script>alert("注册成功！")</script>';
            Header("Location:/testing/pages/login.html"); 
             
         }else{
              echo '<script>alert("注册失败！")</script>';
         }
        
         
    }
        
    ?>
</body>
</html>